package com.ray.study.sample.test.spock.service.impl;

import com.ray.study.sample.test.spock.entity.User;
import com.ray.study.sample.test.spock.mapper.UserMapper;
import com.ray.study.sample.test.spock.service.UserService;
import lombok.AllArgsConstructor;

/**
 * UserService
 *
 * @author ray
 * @date 2020/5/16
 */
@AllArgsConstructor
public class UserServiceImpl implements UserService {

    UserMapper userMapper;

    public User query(User u) {
        if (u.getUsername() != null) {
            return userMapper.findByUserName(u.getUsername());
        } else if (u.getId() != null) {
            return userMapper.findById(u.getId());
        }

        return null;
    }

    public void save(User u) {
        userMapper.save(u);
    }
}
